<%@page import="com.webdemo3.dao.UsersDao"%>
<%@page import="com.webdemo3.bean.UsersBean"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
%>

<%
	String username,upwd,opwd,pwd,gender,birth,phone,addr;
	String errorCode = "0";
	username = request.getParameter("username");
	upwd = request.getParameter("upwd");
	opwd = request.getParameter("opwd");
	pwd = request.getParameter("pwd");
	gender = request.getParameter("gender");
	birth = request.getParameter("birth");
	phone = request.getParameter("phone");
	addr = request.getParameter("addr");
	UsersBean ub = new UsersBean(); 
	ub.setUsername(username);
	ub.setPwd(pwd);
	ub.setGender(gender);
	ub.setBirth(birth);
	ub.setPhone(phone);
	ub.setAddr(addr);
	if(!opwd.equals(upwd)) {
		errorCode = "5";
		response.sendRedirect("update.jsp?username=" + username + "&errorCode=" + errorCode);
		return;
	}
	if( UsersDao.update(ub) != 0) {
		out.println("<script>alert('OK');</script>");
		response.sendRedirect("list.jsp");
	}
	
%>
